package com.yanqu.road.server.cmd.systemgroup.newmonopolymkt.resgrab;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.cmd.CrossAppointCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketGroup;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

import java.util.List;


@Cmd(code = Protocol.C_CROSS_NEW_MONOPOLY_MARKET_RES_GRAB_GET_POINT_REWARD, desc = "批量领取资源点奖励")
public class CrossNewMonopolyMarketResGrabGetPointRewardCmd extends CrossAppointCommand {

    long userId;
    List<NewMonopolyMarketProto.NewMonopolyMarketGetPointRewardTemp> list = null;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        userId = packet.getPlayerId();
        NewMonopolyMarketProto.NewMonopolyMarketGetPointRewardReqMsg req = NewMonopolyMarketProto.NewMonopolyMarketGetPointRewardReqMsg.parseFrom(packet.getBytes());
        list = req.getGetListList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CrossNewMonopolyMarketGroup monopolyMarket = CrossNewMonopolyMarketMgr.getMarket(groupId);
        if(monopolyMarket == null){
            //todo
            return;
        }

        MessageHelper.sendPacket(serverId, userId , YanQuMessageUtils.buildMessage(GameProtocol.S_NEW_MONOPOLY_MARKET_RES_GRAB_GET_POINT_REWARD_FROM_CROSS,
                monopolyMarket.getMarketResRob().getPointReward(userId, serverId, list)));
    }

    @Override
    public void sendData() {

    }
}
